//
// Toolbar
// --------------------------------------------------


// Wrapper and base class
//
// Provide a static toolbar from which we expand to create full-width, fixed, and
// other navbar variations.

.navbar-toolbar {
  min-height: @navbar-toolbar-height; // Ensure a toolbar always shows (e.g., without a .navbar-brand in collapsed mode)
  margin-bottom: @navbar-toolbar-margin-bottom;

  @media (min-width: @grid-float-breakpoint) {
    border-radius: @navbar-toolbar-border-radius;
  }
}


//
// Navbar alignment options
//
// Display the navbar across the entirity of the page or fixed it to the top or
// bottom of the page.

// Static top (unfixed, but 100% wide) navbar
.navbar-toolbar .navbar-static-top {
  z-index: @zindex-toolbar;
}

// Fix the top/bottom navbars when screen real estate supports it
.navbar-toolbar .navbar-fixed-top,
.navbar-toolbar .navbar-fixed-bottom {
  z-index: @zindex-toolbar-fixed;
}


// Brand/project name

.navbar-toolbar .navbar-brand {
  padding: @navbar-toolbar-padding-vertical @navbar-toolbar-padding-horizontal;
  font-size: @navbar-toolbar-brand-font-size;
  font-weight: bold;
  height: @navbar-toolbar-height;

  @media (min-width: @grid-float-breakpoint) {
    .navbar > .container &,
    .navbar > .container-fluid & {
      margin-left: -@navbar-toolbar-padding-horizontal;
    }
  }
}


// Navbar toggle
//
// Custom button for toggling the `.navbar-collapse`, powered by the collapse
// JavaScript plugin.

.navbar-toolbar .navbar-toggle {
  margin-right: @navbar-toolbar-padding-horizontal;
  .navbar-vertical-align(@input-height-base, @navbar-toolbar-height);
}


// Navbar nav links
//
// Builds on top of the `.nav` components with its own modifier class to make
// the nav the full height of the horizontal nav (above 768px).

.navbar-toolbar .navbar-nav {
  margin: floor((@navbar-toolbar-padding-vertical / 2)) -@navbar-toolbar-padding-horizontal;

  > li {
    position: relative;
    > a {
      padding: @navbar-toolbar-padding-vertical @navbar-padding-horizontal;
      &:hover,
      &:focus {
        text-decoration: underline;
      }
    }
    > .dropdown-menu {
      margin-top: 1px;
    }
  }
  > .active > a {
    font-weight: bold;
    &:before {
      position: absolute;
      bottom: -1px;
      left: 50%;
      display: inline-block;
      margin-left: -8px; /* value should match border-width below */
      border-right:  8px solid transparent;
      border-bottom: 8px solid transparent;
      border-left:   8px solid transparent;
      content: '';
    }
    &:after {
      position: absolute;
      bottom: -1px;
      left: 50%;
      display: inline-block;
      margin-left: -7px; /* value should match border-width below */
      border-right:  7px solid transparent;
      border-bottom: 7px solid transparent;
      border-left:   7px solid transparent;
      content: '';
    }
  }

  // Uncollapse the nav
  @media (min-width: @grid-float-breakpoint) {
    margin: 0;

    > li {
      > a {
        padding-top: @navbar-toolbar-padding-vertical;
        padding-bottom: @navbar-toolbar-padding-vertical;
      }
    }
  }
}


// Navbar form
//
// Extension of the `.form-inline` with some extra flavor for optimum display in
// our navbars.

.navbar-toolbar .navbar-form {
  margin-left: -@navbar-toolbar-padding-horizontal;
  margin-right: -@navbar-toolbar-padding-horizontal;
  padding: 10px @navbar-toolbar-padding-horizontal;

  > .input-group .form-control {
    .navbar-vertical-align(@input-height-base, @navbar-toolbar-height);
  }

  .form-group {
    @media (max-width: @grid-float-breakpoint-max) {
      margin-bottom: 5px;
    }
  }

  // Vertically center in expanded, horizontal navbar
  .navbar-vertical-align(@navbar-toolbar-height, @navbar-toolbar-height);

  // Undo 100% width for pull classes
  @media (min-width: @grid-float-breakpoint) {
    margin-left: 0;
    margin-right: 0;
    padding-top: 0;
    padding-bottom: 0;
  }

  .form-control {
    height: @input-height-base;
    padding: @padding-base-vertical @padding-base-horizontal;
  }
}


// Dropdown menus
.navbar-toolbar .dropdown-menu {
  border-top: 1px none;
}

// Buttons in navbars
//
// Vertically center a button within a navbar (when *not* in a form).

.navbar-toolbar {
  &.navbar-btn,
  &.navbar .btn {
    padding: @padding-base-vertical @padding-base-horizontal;
    .navbar-vertical-align(@input-height-base, @navbar-toolbar-height);

    &.btn-sm {
      padding: @padding-small-vertical @padding-small-horizontal;
      .navbar-vertical-align(@input-height-small, @navbar-toolbar-height);
    }
    &.btn-xs {
      padding: @padding-xs-vertical @padding-xs-horizontal;
      .navbar-vertical-align(20, @navbar-toolbar-height);
    }
  }
}


// Text in navbars
//
// Add a class to make any element properly align itself vertically within the navbars.

.navbar-toolbar .navbar-text {
  .navbar-vertical-align(@line-height-computed, @navbar-toolbar-height);
}


// Alternate navbars
// --------------------------------------------------

// Default navbar
.navbar-toolbar.navbar-default {
  background-color: @navbar-toolbar-default-bg;
  border-color: @navbar-toolbar-default-border;

  .navbar-brand {
    color: @navbar-toolbar-default-brand-color;
    &:hover,
    &:focus {
      color: @navbar-toolbar-default-brand-hover-color;
      background-color: @navbar-toolbar-default-brand-hover-bg;
    }
    > .caret {
      border-top-color: @navbar-toolbar-default-brand-color;
      border-bottom-color: @navbar-toolbar-default-brand-color;
    }
  }

  .navbar-text {
    color: @navbar-toolbar-default-color;
  }

  .navbar-nav {
    > li > a {
      color: @navbar-toolbar-default-link-color;

      &:hover,
      &:focus {
        color: @navbar-toolbar-default-link-hover-color;
        background-color: @navbar-toolbar-default-link-hover-bg;
      }
    }
    > .active > a {
      &,
      &:hover,
      &:focus {
        color: @navbar-toolbar-default-link-active-color;
        background-color: @navbar-toolbar-default-link-active-bg;
      }
      &:before {
        border-bottom: 8px solid @navbar-toolbar-default-border;
      }
      &:after {
        border-bottom: 7px solid @dropdown-bg;
      }
    }
    > .disabled > a {
      &,
      &:hover,
      &:focus {
        color: @navbar-toolbar-default-link-disabled-color;
        background-color: @navbar-toolbar-default-link-disabled-bg;
      }
    }
  }

  .navbar-toggle {
    border-color: @navbar-toolbar-default-toggle-border-color;
    &:hover,
    &:focus {
      background-color: @navbar-toolbar-default-toggle-hover-bg;
    }
    .icon-bar {
      background-color: @navbar-toolbar-default-toggle-icon-bar-bg;
    }
  }

  .navbar-collapse,
  .navbar-form {
    border-color: darken(@navbar-toolbar-default-bg, 7%);
  }

  // Dropdown menu items
  .navbar-nav {
    // Remove background color from open dropdown
    > .open > a {
      &,
      &:hover,
      &:focus {
        background-color: @navbar-toolbar-default-link-active-bg;
        color: @navbar-toolbar-default-link-active-color;
      }
    }

    @media (max-width: @grid-float-breakpoint-max) {
      // Dropdowns get custom display when collapsed
      .open .dropdown-menu {
        > li > a {
          color: @navbar-toolbar-default-link-color;
          &:hover,
          &:focus {
            color: @navbar-toolbar-default-link-hover-color;
            background-color: @navbar-toolbar-default-link-hover-bg;
          }
        }
        > .active > a {
          &,
          &:hover,
          &:focus {
            color: @navbar-toolbar-default-link-active-color;
            background-color: @navbar-toolbar-default-link-active-bg;
          }
        }
        > .disabled > a {
          &,
          &:hover,
          &:focus {
            color: @navbar-toolbar-default-link-disabled-color;
            background-color: @navbar-toolbar-default-link-disabled-bg;
          }
        }
      }
    }
  }


  // Links in navbars
  //
  // Add a class to ensure links outside the navbar nav are colored correctly.

  .navbar-link {
    color: @navbar-toolbar-default-link-color;
    &:hover {
      color: @navbar-toolbar-default-link-hover-color;
    }
  }

  .btn-link {
    color: @navbar-toolbar-default-link-color;
    &:hover,
    &:focus {
      color: @navbar-toolbar-default-link-hover-color;
    }
    &[disabled],
    fieldset[disabled] & {
      &:hover,
      &:focus {
        color: @navbar-toolbar-default-link-disabled-color;
      }
    }
  }
}

// Inverse navbar

.navbar-toolbar.navbar-inverse {
  background-color: @navbar-toolbar-inverse-bg;
  border-color: @navbar-toolbar-inverse-border;

  .navbar-brand {
    color: @navbar-toolbar-inverse-brand-color;
    &:hover,
    &:focus {
      color: @navbar-toolbar-inverse-brand-hover-color;
      background-color: @navbar-toolbar-inverse-brand-hover-bg;
    }
    > .caret {
      border-top-color: @navbar-toolbar-inverse-brand-color;
      border-bottom-color: @navbar-toolbar-inverse-brand-color;
    }
  }

  .navbar-text {
    color: @navbar-toolbar-inverse-color;
  }

  .navbar-nav {
    > li > a {
      color: @navbar-toolbar-inverse-link-color;

      &:hover,
      &:focus {
        color: @navbar-toolbar-inverse-link-hover-color;
        background-color: @navbar-toolbar-inverse-link-hover-bg;
      }
    }
    > .active > a {
      &,
      &:hover,
      &:focus {
        color: @navbar-toolbar-inverse-link-active-color;
        background-color: @navbar-toolbar-inverse-link-active-bg;
      }
      &:before {
        border-bottom: 8px solid @navbar-toolbar-inverse-border;
      }
      &:after {
        border-bottom: 7px solid @dropdown-bg;
      }
    }
    > .disabled > a {
      &,
      &:hover,
      &:focus {
        color: @navbar-toolbar-inverse-link-disabled-color;
        background-color: @navbar-toolbar-inverse-link-disabled-bg;
      }
    }
  }

  // Darken the responsive nav toggle
  .navbar-toggle {
    border-color: @navbar-toolbar-inverse-toggle-border-color;
    &:hover,
    &:focus {
      background-color: @navbar-toolbar-inverse-toggle-hover-bg;
    }
    .icon-bar {
      background-color: @navbar-toolbar-inverse-toggle-icon-bar-bg;
    }
  }

  .navbar-collapse,
  .navbar-form {
    border-color: darken(@navbar-toolbar-inverse-bg, 7%);
  }

  // Dropdowns
  .navbar-nav {
    > .open > a {
      &,
      &:hover,
      &:focus {
        background-color: @navbar-toolbar-inverse-link-active-bg;
        color: @navbar-toolbar-inverse-link-active-color;
      }
    }

    @media (max-width: @grid-float-breakpoint-max) {
      // Dropdowns get custom display
      .open .dropdown-menu {
        > .dropdown-header {
          border-color: @navbar-toolbar-inverse-border;
        }
        .divider {
          background-color: @navbar-toolbar-inverse-border;
        }
        > li > a {
          color: @navbar-toolbar-inverse-link-color;
          &:hover,
          &:focus {
            color: @navbar-toolbar-inverse-link-hover-color;
            background-color: @navbar-toolbar-inverse-link-hover-bg;
          }
        }
        > .active > a {
          &,
          &:hover,
          &:focus {
            color: @navbar-toolbar-inverse-link-active-color;
            background-color: @navbar-toolbar-inverse-link-active-bg;
          }
        }
        > .disabled > a {
          &,
          &:hover,
          &:focus {
            color: @navbar-toolbar-inverse-link-disabled-color;
            background-color: @navbar-toolbar-inverse-link-disabled-bg;
          }
        }
      }
    }
  }

  .navbar-link {
    color: @navbar-toolbar-inverse-link-color;
    &:hover {
      color: @navbar-toolbar-inverse-link-hover-color;
    }
  }

  .btn-link {
    color: @navbar-toolbar-inverse-link-color;
    &:hover,
    &:focus {
      color: @navbar-toolbar-inverse-link-hover-color;
    }
    &[disabled],
    fieldset[disabled] & {
      &:hover,
      &:focus {
        color: @navbar-toolbar-inverse-link-disabled-color;
      }
    }
  }
}
